using GOPATH mode
<!DOCTYPE html>
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="theme-color" content="#375EAB">

	<title>mymarshal - Go Documentation Server</title>

	<link type="text/css" rel="stylesheet" href="static/style.css">

	<script>window.initFuncs = [];</script>
	<script src="static/jquery.js" defer></script>



	<script>var goVersion = "go1.13.8";</script>
	<script src="static/godocs.js" defer></script>
</head>

<body>

	<div id='lowframe'
		style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
		...
	</div><!-- #lowframe -->

	<div id="topbar" class="wide">
		<div class="container">
			<div class="top-heading" id="heading-wide"><a href="/pkg/">Go Documentation Server</a></div>
			<div class="top-heading" id="heading-narrow"><a href="/pkg/">GoDoc</a></div>
			<a href="#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
			<form method="GET" action="/search">
				<div id="menu">

					<span class="search-box"><input type="search" id="search" name="q" placeholder="Search"
							aria-label="Search" required><button type="submit"><span>
								<!-- magnifying glass: --><svg width="24" height="24" viewBox="0 0 24 24">
									<title>submit search</title>
									<path
										d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
									<path d="M0 0h24v24H0z" fill="none" />
								</svg></span></button></span>
				</div>
			</form>

		</div>
	</div>



	<div id="page" class="wide">
		<div class="container">


			<h1>
				Package mymarshal
				<span class="text-muted"></span>
			</h1>







			<div id="nav"></div>


			<!--
	Copyright 2009 The Go Authors. All rights reserved.
	Use of this source code is governed by a BSD-style
	license that can be found in the LICENSE file.
-->
			<!--
	Note: Static (i.e., not template-generated) href and id
	attributes start with "pkg-" to make it impossible for
	them to conflict with generated attributes (some of which
	correspond to Go identifiers).
-->

			<script>
				document.ANALYSIS_DATA = null;
				document.CALLGRAPH = null;
			</script>



			<div id="short-nav">
				<dl>
					<dd><code>import "gitee.com/xiezhx9/mymarshal"</code></dd>
				</dl>
				<dl>
					<dd><a href="#pkg-overview" class="overviewLink">Overview</a></dd>
					<dd><a href="#pkg-index" class="indexLink">Index</a></dd>

					<dd><a href="#pkg-examples" class="examplesLink">Examples</a></dd>


				</dl>
			</div>
			<!-- The package's Name is printed as title by the top-level template -->
			<div id="pkg-overview" class="toggleVisible">
				<div class="collapsed">
					<h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
				</div>
				<div class="expanded">
					<h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>


				</div>
			</div>

			<div id="pkg-index" class="toggleVisible">
				<div class="collapsed">
					<h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
				</div>
				<div class="expanded">
					<h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>

					<!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
					<div id="manual-nav">
						<dl>




							<dd><a href="#JsonMarshal">func JsonMarshal(v interface{}) ([]byte, error)</a></dd>


							<dd><a href="#StructtoString">func StructtoString(v interface{}) string</a></dd>


							<dd><a href="#ValuetoString">func ValuetoString(v interface{}) string</a></dd>



							<dd><a href="#InvalidTypeException">type InvalidTypeException</a></dd>



							<dd>&nbsp; &nbsp; <a href="#InvalidTypeException.Error">func (v InvalidTypeException)
									Error() string</a></dd>



						</dl>
					</div><!-- #manual-nav -->


					<div id="pkg-examples">
						<h3>Examples</h3>
						<div class="js-expandAll expandAll collapsed">(Expand All)</div>
						<dl>

							<dd><a class="exampleLink" href="#example_JsonMarshal">JsonMarshal</a></dd>

							<dd><a class="exampleLink" href="#example_StructtoString">StructtoString</a></dd>

							<dd><a class="exampleLink" href="#example_ValuetoString">ValuetoString</a></dd>

						</dl>
					</div>



					<h3>Package files</h3>
					<p>
						<span style="font-size:90%">

							<a href="/src/gitee.com/xiezhx9/mymarshal/marshal.go">marshal.go</a>

						</span>
					</p>

				</div><!-- .expanded -->
			</div><!-- #pkg-index -->








			<h2 id="JsonMarshal">func <a
					href="/src/gitee.com/xiezhx9/mymarshal/marshal.go?s=1739:1786#L67">JsonMarshal</a>
				<a class="permalink" href="#JsonMarshal">&#xb6;</a>


			</h2>
			<pre>func JsonMarshal(v interface{}) ([]<a href="/pkg/builtin/#byte">byte</a>, <a href="/pkg/builtin/#error">error</a>)</pre>
			<p>
				JsonMarshal 是整个包的核心函数
			</p>

			<div id="example_JsonMarshal" class="toggle">
				<div class="collapsed">
					<p class="exampleHeading toggleButton">▹ <span class="text">Example</span></p>
				</div>
				<div class="expanded">
					<p class="exampleHeading toggleButton">▾ <span class="text">Example</span></p>



					<p>Code:</p>
					<pre class="code">
x := []float64{1.0, 2.0, 156156165.5, 46546.16}
group := ColorGroup{
    ID:    1,
    Name:  &#34;Reds&#34;,
    Hello: x,
}
testt, _ := JsonMarshal(&amp;group)
println(string(testt)) <span class="comment">//{&#34;ID&#34;:1,&#34;Name&#34;:&#34;Reds&#34;,&#34;Hello&#34;:[1]}</span>

</pre>


				</div>
			</div>






			<h2 id="StructtoString">func <a
					href="/src/gitee.com/xiezhx9/mymarshal/marshal.go?s=322:363#L7">StructtoString</a>
				<a class="permalink" href="#StructtoString">&#xb6;</a>


			</h2>
			<pre>func StructtoString(v interface{}) <a href="/pkg/builtin/#string">string</a></pre>
			<p>
				StructtoString 是用来处理结构体转成字符串使用的
			</p>

			<div id="example_StructtoString" class="toggle">
				<div class="collapsed">
					<p class="exampleHeading toggleButton">▹ <span class="text">Example</span></p>
				</div>
				<div class="expanded">
					<p class="exampleHeading toggleButton">▾ <span class="text">Example</span></p>



					<p>Code:</p>
					<pre class="code">
type Class struct {
    Name  string `json:&#34;name&#34;`
    Grade int
}
type Stu struct {
    Name  string `json:&#34;name&#34;`
    Age   int
    HIgh  bool
    sex   string
    Class *Class `json:&#34;class&#34;`
}

stu := Stu{
    Name: &#34;张三&#34;,
    Age:  18,
    HIgh: true,
    sex:  &#34;男&#34;,
}

<span class="comment">//指针变量</span>
cla := new(Class)
cla.Name = &#34;1班&#34;
cla.Grade = 3
stu.Class = cla

str := StructtoString(stu)
println(str) <span class="comment">//{&#34;name&#34;:&#34;张三&#34;,&#34;Age&#34;:18,&#34;HIgh&#34;:true,&#34;class&#34;:{&#34;name&#34;:&#34;1班&#34;,&#34;Grade&#34;:3}}</span>
</pre>


				</div>
			</div>






			<h2 id="ValuetoString">func <a
					href="/src/gitee.com/xiezhx9/mymarshal/marshal.go?s=866:906#L31">ValuetoString</a>
				<a class="permalink" href="#ValuetoString">&#xb6;</a>


			</h2>
			<pre>func ValuetoString(v interface{}) <a href="/pkg/builtin/#string">string</a></pre>
			<p>
				ValuetoString 是用来处理任意对象转为字符串使用的
			</p>

			<div id="example_ValuetoString" class="toggle">
				<div class="collapsed">
					<p class="exampleHeading toggleButton">▹ <span class="text">Example</span></p>
				</div>
				<div class="expanded">
					<p class="exampleHeading toggleButton">▾ <span class="text">Example</span></p>



					<p>Code:</p>
					<pre class="code">
println(ValuetoString(true)) <span class="comment">//true</span>
println(ValuetoString(1.0))  <span class="comment">//1</span>
println(ValuetoString(1))    <span class="comment">//1</span>
</pre>


				</div>
			</div>







			<h2 id="InvalidTypeException">type <a
					href="/src/gitee.com/xiezhx9/mymarshal/marshal.go?s=161:193#L1">InvalidTypeException</a>
				<a class="permalink" href="#InvalidTypeException">&#xb6;</a>


			</h2>
			<p>
				InvalidTypeException 是不正常类型异常,因为有些类型Marshal序列化以后得不到值
			</p>

			<pre>type InvalidTypeException <a href="/pkg/builtin/#string">string</a></pre>













			<h3 id="InvalidTypeException.Error">func (InvalidTypeException) <a
					href="/src/gitee.com/xiezhx9/mymarshal/marshal.go?s=195:239#L2">Error</a>
				<a class="permalink" href="#InvalidTypeException.Error">&#xb6;</a>


			</h3>
			<pre>func (v <a href="#InvalidTypeException">InvalidTypeException</a>) Error() <a href="/pkg/builtin/#string">string</a></pre>
















			<div id="footer">
				Build version go1.13.8.<br>
				Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
				the content of this page is licensed under the
				Creative Commons Attribution 3.0 License,
				and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
				<a href="/doc/tos.html">Terms of Service</a> |
				<a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
			</div>

		</div><!-- .container -->
	</div><!-- #page -->
</body>

</html>